package rpc.netty.tcp.entity;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/*********
 *
 *
 *@author 197
 *@date 2020/6/19 18:10
 *
 **/


public class RpcMessage {

  private final static byte flag = 0X0F;
  /**
   * 0 业务 1 心跳
   */
  private int type = 0;

  private int serviceId;
  private int msgId;
  private Map<String, Object> data;
  private MessageHeader messageHeader;

  /****
   *TraceId
   */

  private Map<String, Object> rpcProData;

  public RpcMessage(int type, int serviceId, int msgId, Map<String, Object> data,
      Map<String, Object> rpcProMap, MessageHeader messageHeader) {
    this.type = type;
    this.serviceId = serviceId;
    this.msgId = msgId;
    this.data = Objects.nonNull(data) ? data : new HashMap<>();
    this.rpcProData = Objects.nonNull(rpcProMap) ? rpcProMap : new HashMap<>();
    this.messageHeader = Objects.nonNull(messageHeader) ? messageHeader : new MessageHeader();
  }


  public static byte getFlag() {
    return RpcMessage.flag;

  }

  public int getType() {
    return type;
  }

  public RpcMessage setType(int type) {
    this.type = type;
    return this;
  }

  public int getServiceId() {
    return serviceId;
  }

  public RpcMessage setServiceId(int serviceId) {
    this.serviceId = serviceId;
    return this;
  }

  public int getMsgId() {
    return msgId;
  }

  public RpcMessage setMsgId(int msgId) {
    this.msgId = msgId;
    return this;
  }

  public Map<String, Object> getData() {
    return data;
  }

  public RpcMessage setData(Map<String, Object> data) {
    this.data = data;
    return this;
  }

  public MessageHeader getMessageHeader() {
    return messageHeader;
  }

  public RpcMessage setMessageHeader(MessageHeader messageHeader) {
    this.messageHeader = messageHeader;
    return this;
  }

  public Map<String, Object> getRpcProData() {
    return rpcProData;
  }

  public RpcMessage setRpcProData(Map<String, Object> rpcProData) {
    this.rpcProData = rpcProData;
    return this;
  }
}
